<template>
  <svg :class="svgClass">
    <use :xlink:href="iconName" :fill="color" />
  </svg>
</template>

<script setup lang="ts" name="SvgIcon">
const props = withDefaults(
  defineProps<{
    iconClass: string
    className?: string
    color?: string
  }>(),
  {
    className: '',
    color: ''
  }
)

const iconName = computed(() => `#icon-${props.iconClass}`)
const svgClass = computed(() => {
  return 'svg-icon ' + props.className
})
</script>

<style scope lang="scss">
.sub-el-icon,
.nav-icon {
  display: inline-block;
  position: relative;
  margin-right: 12px;
  font-size: 15px;
}

.svg-icon {
  position: relative;
  width: 1em;
  height: 1em;
  fill: currentColor;
  vertical-align: -2px;
}
</style>
